package com.neutech.neusys.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.neutech.neusys.service.DiseCategoryService;
import com.neutech.neusys.service.DiseaseService;
import com.neutech.po.DiseCategory;
import com.neutech.po.Disease;


@RestController
@RequestMapping("/neusys/dise")
public class DiseController {
	@Autowired
	private DiseaseService diseaseService;
	@Autowired
	private DiseCategoryService diseCategoryService;
	//添加疾病
	@RequestMapping(value="/adddisease",method=RequestMethod.POST)
	public String addNewDisease(Disease disease){
		int result = diseaseService.addDisease(disease);
		if(result==1){
			return "success";
		}else{
			return "error";
		}
	}
	//查询疾病分类
	@RequestMapping(value="/getDiseCategory")
	public List<DiseCategory> getDiseCategory(){
		return diseaseService.getDiseCategory();		
	}
	//添加疾病分类
	@RequestMapping(value="/addDiseCategory",method=RequestMethod.POST)
	public String addNewDiseCategory(@RequestBody DiseCategory diseCategory){
		System.out.println(diseCategory.getDicaName());
		diseCategoryService.addDiseCategory(diseCategory);
		int result = diseCategoryService.addDiseCategory(diseCategory);
		if(result==1){
			return "success";
		}else{
			return "error";
		}
	}
	
}
